<?php
use App\Http\Resources\CustomerHistory as Resource;
use App\Models\Company;
use App\Models\ContactInfo;
use App\Models\CustomerHistory;
use Carbon\Carbon;
use App\Events\CustomerHistoryCreated;
use GuzzleHttp\Client;
use App\Services\NikkeiService;

//use Symfony\Component\Routing\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
// Route::get("/hash", function () {
// //     $hour = 15;
// //     $minute = 0;
// //     $second = 0;
// //     //$tz = 'Asia/Tokyo';
// //     $r = Carbon::createFromTimeString("$hour:$minute:$second");

// //    // $d = Carbon::now('Asia/Tokyo')->diffInMinutes($r);
// //     $d = $r->diffInMinutes(now(), false);
// //     dump($d);
//     //dump(now("15:00:00", 'PRC')->toDateTimeString());
//     return hash('sha256', 'abc&1e243f8a-d38d-4251-9e92-b3f0366293a3');
// });

// Route::get('/test', function () {
//     Carbon::setTestNow("10:00:00");
//     dump(now());
// });

Route::get('/hash', function () {
    $key = Company::where('company_id', 'insite')->value('api_authentication_key');
    dump(hash('sha256', 'abc&' . $key));
    //dump(now()->diffInYears('2022-10-01', false) * -1);
});

Route::prefix('admin')->namespace('Admin')->name('admin.')->middleware('auth:admin')->group(function() {
    Route::get('/', "IndexController@index")->name('index');
    Route::resource('/inputgroup', "InputGroupController");
    Route::resource('inputgroup.items', 'ItemsController')->shallow();
    Route::resource('item.option', 'OptionController')->shallow();
    Route::get('history', 'CustomerHistoryController@index')->name('history.index');
    Route::get('history/{history}', 'CustomerHistoryController@show')->name('history.show');
    Route::resource('/company', 'CompanyController');
    Route::resource('/nikkeiscorerate', 'NikkeiScoreRateController');
    Route::resource('/scorerank', 'ScoreRankController');
    Route::get('/contact', 'ContactInfoController@index')->name('contact.index');
    Route::delete('/contact/{contact}', 'ContactInfoController@destroy')->name('contact.destroy');
    Route::post('logout', 'AuthController@logout');
});

Route::get('admin/login', 'Admin\AuthController@showLoginForm')->name('admin.showLoginForm');
Route::post('admin/login', 'Admin\AuthController@login')->name('admin.login');














